package com.ella.controller;
import com.ella.entity.Result;
import com.ella.entity.SysUser;
import com.ella.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author 浮生若梦
 * @since 2023-05-07
 */
@RestController
@RequestMapping("/sys-user")
public class SysUserController{

	@Resource
	private ISysUserService sysUserService;

	@PostMapping( "/login")
	public Result userLogin(@RequestParam("loginName") String loginName, @RequestParam("password") String password) throws Exception {
		// 生成令牌  TODO 这一点前端是将登录账号放在了url中,后面再改
		SysUser sysUser =  new SysUser();
		sysUser.setLoginName(loginName);
		sysUser.setPassword(password);
		return  sysUserService.login(sysUser);
	}

	@PostMapping("/list")
	@PreAuthorize("hasAuthority('monitor:druid:list')")
	public Result userList(@RequestHeader(required = false)String token){
		return Result.ok();
	}

}

